Organizing the elements in a list dialog

I have created a script that displays the user modifiable attributes for a module in a multilist and allows the user to select one or more attributes from the multilist and add them to a new list on the same dialog box form. Doing so removes the attribute from the multilist and displays it in the list.

I am using a skip list to store the attributes that are added to the list. However, I would like to allow the user to order the attributes in the list (much like in the DOORS "Edit Enumerations dialog" where the user selects an item in the list and then clicks on the up and down arrow buttons on the screen to cause the list order to change.

I thought about using an integer for the key, but there's a 'find' function to see if the item being added to the list from the multilist is already in the skip, and because 'find' uses the key, I can't use a number for the key.

I could set the key to be a number and then do a for loop to go through the elements in the list to see if the entry is already present, but that seems like it might take more resources than the 'find' function.

Anyone have any ideas on how to make this sorting task easy and efficient?
ZenMonkey760 - Tue Apr 27 21:12:40 EDT 2010

Re: Organizing the elements in a list dialog
Mathias Mamsch - Wed Apr 28 03:16:54 EDT 2010

Ok i guess this question is for educational purposes? I think you really do not need to worry about efficiency and ressources regarding a GUI dialog :-)

Obviously using a position as a key is a possibility. But why? You have a multilist that is just like a skip list! With get(int pos) you can get the element at position pos. And you have the other Skip with the names as keys (store the positions as values, but only if you need to find the position of a value very quickly), then you will have all the information you need.

Moving items up and down is nothing more like, getting the content of position i, the content of position i+1 (for down, i-1 for up) and swapping the values in the skip list. I gues there is no need to keep the positions in a separate list.

Mathias Mamsch, IT-QBase GmbH